﻿using System;
using System.Windows.Input;
using DynamicModel;
using DynamicMVVMDemo.Wpf.Models;
using DynamicMVVM;

namespace DynamicMVVMDemo.Wpf.ViewModels
{
    public class PersonDetailsViewModel : DynamicViewModel
    {
        //public ICommand SaveCommand { get; set; }
        //public ICommand CancelCommand { get; set; }

        public PersonDetailsViewModel()
        {
            Model = new DynamicMVVM.DynamicModel(new Person
                                         {
                                             Id = 1,
                                             FName = "Abc",
                                             LName = "Xyz",
                                             Dob = new DateTime(2011, 1, 1),
                                             Active = true,
                                             Salary = 12345

                                         }
            );

            //SaveCommand = new RelayCommand((object obj) =>
            //                                   {
            //                                       //your stuff
            //                                   }, (object obj) => Model.IsDirty);
            //CancelCommand = new RelayCommand((object obj) =>
            //                                     {
            //                                         //your stuff
            //                                     }, (object obj) => Model.IsDirty);
        }

        public DynamicMVVM.DynamicModel Model { get; set; }

        public bool CanExecuteCancel(DynamicMVVM.DynamicModel o)
        {
            return Model.IsDirty;
        }
        public void ExecuteCancel(DynamicMVVM.DynamicModel o)
        {
            ;
        }

        public bool CanExecuteSave(DynamicMVVM.DynamicModel o)
        {
            return Model.IsDirty;
        }

        public void ExecuteSave(DynamicMVVM.DynamicModel o)
        {
            ;
        }

    }
}
